//
//  SettingCell.m
//  DriverClient
//
//  Created by 吕晶 on 2020/8/3.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "SettingCell.h"

@interface SettingCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *descLab;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIImageView *arrowImgView;
@property (nonatomic, strong) UILabel *line;

@end

@implementation SettingCell

+ (instancetype)SettingCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"SettingCell";
    SettingCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[SettingCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, ScreenW - 30, 60)];
        self.bgView.backgroundColor = HexColor(0xffffff);
        [self.contentView addSubview:self.bgView];
        
        self.line = [[UILabel alloc] initWithFrame:CGRectMake(10, self.bgView.nim_height - 1, self.bgView.nim_width - 20, 1)];
        self.line.backgroundColor = HexColor(0xF2F2F5);
        self.line.hidden = YES;
        [self.bgView addSubview:self.line];
        
        self.arrowImgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bgView.nim_width - 15 - 24, 18, 24, 24)];
        self.arrowImgView.image = [UIImage imageNamed:@"icon_getinto"];
        [self.bgView addSubview:self.arrowImgView];
        
        self.titleLab = [[UILabel alloc] initWithFrame:CGRectMake(10, (60 - 17) * 0.5, (self.arrowImgView.nim_left - 10) * 0.4, 17)];
        self.titleLab.textColor = HexColor(0x585974);
        self.titleLab.font = [UIFont systemFontOfSize:16];
        [self.bgView addSubview:self.titleLab];
        
        self.descLab = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLab.nim_right, (60 - 17) * 0.5, (self.arrowImgView.nim_left - 10) * 0.6, 17)];
        self.descLab.textColor = HexColor(0x585974);
        self.descLab.font = [UIFont systemFontOfSize:16];
        self.descLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.descLab];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

-(void)setTitleText:(NSString *)titleText {
    _titleText = titleText;
    self.titleLab.text = titleText;
}

-(void)setDescText:(NSString *)descText {
    _descText = descText;
    self.descLab.text = descText;
}

-(void)setShowLine:(BOOL)showLine {
    _showLine = showLine;
    self.line.hidden = !showLine;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
